import Vue from "vue";
import MessageCompent from "./Message"
//获取当前组件的实例
let getInstance =()=>{
    let vm = new Vue({
        render:h=>h(MessageCompent)
    }).$mount();//会在内存中进行挂载
    document.body.appendChild(vm.$el);
    //父组件拿子组件的方法
    let compent = vm.$children[0];
    return {
        add(options){
            compent.add(options)
        }
    }
    

}
//性能影响 做成单例模式
let instance;
let getInst = ()=>{
    instance = instance || getInstance();
    return instance;
}
const Message = {
    info(options){
        getInst().add(options)
    },
    success(){

    },
    warning(){

    },
    error(){

    }
}
export {
    Message
}